package com.work.demo.file;

import java.io.File;
import java.io.IOException;

public class TestFile {
	public static void main(String[] args) throws IOException {
		File file = new File(".");

		System.out.println(file.getName());

		System.out.println(file.getParent());

		System.out.println(file.getAbsoluteFile());

		System.out.println(file.getAbsoluteFile().getParent());

		File tempFile = File.createTempFile("aaa", ".txt", file);

		//tempFile.deleteOnExit();

		File newFile = new File(System.currentTimeMillis() + "");

		System.out.println("对象是否存在:" + newFile.exists());

		newFile.createNewFile();

		newFile.mkdirs();

		String[] list = file.list();

		for (String fileName : list) {
			System.out.println("文件名:" + fileName);
		}

		File[] files = File.listRoots();

		for (File file1 : files) {
			System.out.println(file1 + "-------");
		}

	}
}
